//
//  AppDelegate.m
//  ZMUnderFrameWorkDemo
//
//  Created by MAC on 2020/1/8.
//  Copyright © 2020 MAC. All rights reserved.
//

#import "AppDelegate.h"
#import "LoginHomeVC.h"

@interface AppDelegate ()

@end

@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [self initRootWithType:1 vc:nil];
    return YES;
}

/// 初始化根视图
-(void)initRootWithType:(NSInteger)type vc:(UIViewController *)vc{
    switch (type) {
        case 0:{
            LoginHomeVC *loginVC = [[LoginHomeVC alloc] init];
            RTRootNavigationController *nav = [[RTRootNavigationController alloc]initWithRootViewController:loginVC];
            if (vc) {
                nav.modalPresentationStyle = UIModalPresentationFullScreen;
                [vc presentViewController:nav animated:YES completion:nil];
            }else{
                self.window.rootViewController = loginVC;
            }
        }break;
        case 1:{
            self.window.rootViewController = self.tabBarCt;
        }break;
        default:
            break;
    }
}

#pragma mark - 推送跳转
- (void)pushVC:(NSString *)pushStr {
    if (kIsEmptyStr(pushStr)) {
        return;
    }
    if ([self.window.rootViewController isKindOfClass:[MainTabBarController class]]) {
        [kAppDelegate.tabBarCt jj_messagePushVC:nil url:pushStr title:@"1" sourceType:SourceTypePush];
        self.pushUrlStr = nil;
    } else {
        self.pushUrlStr = pushStr;
    }
}

#pragma mark- Lazyload
-(MainTabBarController *)tabBarCt{
    if (!_tabBarCt) {
        _tabBarCt=[[MainTabBarController alloc]init];
    }
    return _tabBarCt;
}

-(UIWindow *)window{
    if (!_window) {
        _window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        [_window makeKeyAndVisible];
    }
    return _window;
}

@end
